package com.whjfxx.terminal.utils;

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created by b.c on 2022/4/13 9:51
 */
public class MD5Util {

    public static String encode(String ... strArr) {
        try {
            StringBuilder str = new StringBuilder();
            for (String s : strArr) {
                str.append(s);
            }
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            byte[] digest  = messageDigest.digest(str.toString().getBytes(StandardCharsets.UTF_8));
            String md5Str = new BigInteger(1, digest).toString(16);
            return md5Str.toUpperCase();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("failed to encode.");
        }
    }


    public static void main(String[] args) {
        System.out.println(encode("医疗系统1.0.01读卡库20220625153134{\"lon\":\"113.619608\",\"lat\":\"28.362147\"}1812CA801936APOS A810bf58c457a72244cda9ae79436b3f9d63"));
    }
}
